package com.example.lol.ui;

import android.graphics.Typeface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.lol.R;
import com.example.lol.ui.adapter.NewsAdapter;
import com.example.lol.ui.adapter.NewsAdapter2;
import com.example.lol.ui.bean.NewBean;
import com.example.lol.ui.bean.NewBean2;

import java.util.ArrayList;
import java.util.List;

public class FourthHomeFragment extends Fragment {
    private String[] title = new String[]{"【天神裁决天使】4裁决4天神2宗师",
            "【重装拉夫】4重装3龙魂3战神",
            "【七法龙王】7魔法师3森林3龙魂",
            "【重秘神射】4神射2重装2秘术",
            "【决斗宗师】6决斗2玉剑2宗师"
    };
    private String[] title1 = new String[]{"虎牙|king亚索",
            "斗鱼|梨落秋溪",
            "斗鱼|迅哥、雨霖铃",
            "虎牙、无敌李夫人",
            "虎牙 宝子"
    };
    private int[] cover = new int[]{R.drawable.ic_people_1,
            R.drawable.ic_people_2,
            R.drawable.ic_people_3,
            R.drawable.ic_people_4,
            R.drawable.ic_people_5};
    private int[] cover1 = new int[]{R.drawable.ic_zrtp,
            R.drawable.ic_zrtj1,
            R.drawable.ic_zrtj2,
            R.drawable.ic_zrtj3,
            R.drawable.ic_zrtj4};
    private List<NewBean2> initData() {
        List<NewBean2> list = new ArrayList<>();
        for (int i=0;i<5;i++){
            list.add(new NewBean2(title[i % title.length],title1[i % title1.length],cover1[i % cover1.length],cover[i % cover.length],5));
        }
        return list;
    }
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home_4, container, false);
        TextView tex=view.findViewById(R.id.zr_btn);
        TextView tex2=view.findViewById(R.id.zlzg_btn);
        tex.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        tex.setTextSize(15);
        tex.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                tex.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                tex.setTextSize(15);
                tex2.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
            }
        });
        tex2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                tex2.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                tex2.setTextSize(15);
                tex.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
            }
        });
        RecyclerView textView = view.findViewById(R.id.yd_recycler);
        textView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        NewsAdapter2 newsAdapter=new NewsAdapter2(initData());
        newsAdapter.setList(initData());
        textView.setAdapter(newsAdapter);
        return view;
    }
}
